package cn.javaeye.lonlysky.lforum.web;

import java.util.List;

import org.apache.struts2.config.ParentPackage;

import cn.javaeye.lonlysky.lforum.ForumBaseAction;
import cn.javaeye.lonlysky.lforum.comm.LForumRequest;
import cn.javaeye.lonlysky.lforum.entity.forum.Users;
import cn.javaeye.lonlysky.lforum.entity.web.Info;
import cn.javaeye.lonlysky.lforum.entity.web.ParentType;
import cn.javaeye.lonlysky.lforum.service.InfoManager;

@ParentPackage("default")
public class AddArticleAction extends ForumBaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8171806380664339042L;
	
	private ParentType parentType;
	private Info info;
	private List<Info> infoList;
	private Users user;
	private InfoManager infoManager;
	
	public String execute() throws Exception {
		if (LForumRequest.getParamValue("list").equals("true")) {
			return SUCCESS;
		}
		if (info!=null) {
			info.setUser(user);
			infoManager.save(info);
			return SUCCESS;
		}

		return INPUT;
	}
	
	public List<Info> getInfoList() {
		return infoList;
	}

	public void setInfoList(List<Info> infoList) {
		this.infoList = infoList;
	}

	public ParentType getParentType() {
		return parentType;
	}
	public void setParentType(ParentType parentType) {
		this.parentType = parentType;
	}
	public Info getInfo() {
		return info;
	}
	public void setInfo(Info info) {
		this.info = info;
	}
	public Users getUser() {
		return user;
	}
	public void setUser(Users user) {
		this.user = user;
	}

	public InfoManager getInfoManager() {
		return infoManager;
	}

	public void setInfoManager(InfoManager infoManager) {
		this.infoManager = infoManager;
	}
}
